#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/videodev2.h>
#include <string.h>
#include <sys/mman.h>
#include <assert.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>

using namespace std;
using namespace cv;

/**
 * https://www.cnblogs.com/siahekai/p/11000789.html
 * https://www.cnblogs.com/Jack-Lee/p/3652957.html
 */

typedef cv::Point3_<uint8_t> Pixel;

int main2() {
	Mat img1(10, 10, CV_8UC3, Scalar(10, 10, 255));
	Mat img2(10, 10, CV_8UC3, Scalar(255, 25, 40));
	Mat img3;
	addWeighted(img1, 0.1, img2, 0.9, 0, img3);
	int x, y, z;
	x = (int) (10 * 0.1 + 255 * 0.9);
	y = (int) (10 * 0.1 + 25 * 0.9);
	z = (int) (255 * 0.1 + 40 * 0.9);

	for (Pixel p : cv::Mat_<Pixel>(img3)) {
		printf("%d\n", x);
		printf("%d\n", y);
		printf("%d\n", z);

		printf("%d\n", p.x);
		printf("%d\n", p.y);
		printf("%d\n", p.z);
	}

	imwrite("out.jpg", img3);
	return 0;
}

int main3() {
	Mat img1 = imread("in.jpg", IMREAD_UNCHANGED);
	Mat img2 = imread("in2.jpg", IMREAD_UNCHANGED);
	Mat img3;
	addWeighted(img1, 0.1, img2, 0.9, 0, img3);
	imwrite("out.jpg", img3);
	return 0;
}


int main4() {
	Mat img = (Mat_<float>(4, 3) << 1, 2, 3, 4,
			                        5, 6, 7, 8,
									9, 10,11,12
									);
	Mat img2;
	cout << img << endl;
	img2= img.t();
	cout << img2 << endl;
	return 0;
}


int main() {
	Mat img = imread("in.jpg", IMREAD_UNCHANGED);
	Mat img2;
	img2= img.t();
	Mat img3 = img2.t();
	imwrite("out.jpg", img3);
	return 0;
}




